const configModel = require('@/models/config.model')
const JsonResult = require('@/utils/httpResponse.unit')
class ConfigController {
  async getClientConfig (req, response) {
    try {
      const config = await configModel.find()
      const { siteName, recordNo, copyright, version, siteLogo } = config || {}
      JsonResult.success({
        req,
        response,
        data: {
          siteName,
          recordNo,
          copyright,
          version,
          siteLogo
        },
        message: '查询配置信息成功'
      })
    } catch (error) {
      JsonResult.fail({ req, response, error, message: '查询配置信息失败' })
    }
  }

  async getFriendLink (req, response) {
    try {
      const data = await configModel.findFriendLink()
      JsonResult.success({
        req,
        response,
        data,
        message: '查询成功'
      })
    } catch (error) {
      JsonResult.fail({ req, response, error, message: '查询失败' })
    }
  }
}

module.exports = new ConfigController()
